<template>
	<view class="topic-detail">
		<topic-detail-head :topic="topic"></topic-detail-head>
		<view class="uni-tab-bar">
			<scroll-list-head :tabsList="tabs" :startFlex="true" :currentTab="currentTab" @changeTab="selectTab"></scroll-list-head>
		</view>
		<view>
			<moment v-for="(item,index) in momentList[currentTab].list" :key="index" :moment="item.moment"></moment>
			<load-more :text="momentList[currentTab].loadtext"></load-more>
		</view>
	</view>
</template>

<script>
	
	
	import scrollListHead from "../../components/scroll-list/scroll-list-head.vue"
	
	import Moment from "../../components/common/moment.vue"
	import loadMore from "../../components/loadmore.vue"
	import NoMsg from "../../components/nomsg.vue"
	
	import topicDetailHead from "../../components/topic-detail/topic-detail-head.vue"

	import TopicData from "../../common/mock/topicdata.js"
	import MomentData from "../../common/mock/momentdata.js"
	
	export default {
		data() {
			return {
				currentTab: 0,
				tabs: ["默认","最新"],
				topic: TopicData.list[0].topic,
				momentList: [{
					loadtext: "加载更多",
					list: MomentData.list
				},{
					loadtext: "加载更多",
					list: MomentData.list
				}]
			}
		},
		onLoad() {
			// console.log(MomentData)
		},
		components:{
			topicDetailHead,
			scrollListHead,
			loadMore,
			Moment
		},
		methods: {
			selectTab(index){
				this.currentTab = index
			}
		},
		onPullDownRefresh(){
			setTimeout(() => {
				this.momentList[this.currentTab]['list'] = [{
						moment: {
							uhead: "../../static/test/head.png",
							uname: "攒拢爱的速递",
							uage: 20,
							ugender: 1, // 0 boy 1 girl -1 
							me: {
								isFollow: true,
								isShare: false,
								iscomment: false,
								isThumb: true
							},
							mtitle: "暗淡担担面，阿妈的模式",
							mtype: 0, // 0 正常  1 视频 2 分享 
							mfimage: "../../static/test/banner2.jpg", // 封面图
							video: {
								playnum: '22w',
								long: '2:47'
							},
							share: {
								mfimage: "../../static/test/banner2.jpg",
								mtitle: "阿呆苏东坡爱搜大叔大妈"
							},
							location: "深圳 - 龙岗",
							shareNum: 200,
							commentNum: 200,
							thumbNum: 200
						}
					}]
					uni.stopPullDownRefresh();
			},2000)	
		},
		onReachBottom() {
			this.momentList[this.currentTab]['loadtext'] = "加载中..."
			setTimeout(() => {
				this.momentList[this.currentTab]['list'].push({
						moment: {
							uhead: "../../static/test/head.png",
							uname: "攒拢爱的速递",
							uage: 20,
							ugender: 1, // 0 boy 1 girl -1 
							me: {
								isFollow: true,
								isShare: false,
								iscomment: false,
								isThumb: true
							},
							mtitle: "暗淡担担面，阿妈的模式",
							mtype: 0, // 0 正常  1 视频 2 分享 
							mfimage: "../../static/test/banner2.jpg", // 封面图
							video: {
								playnum: '22w',
								long: '2:47'
							},
							share: {
								mfimage: "../../static/test/banner2.jpg",
								mtitle: "阿呆苏东坡爱搜大叔大妈"
							},
							location: "深圳 - 龙岗",
							shareNum: 200,
							commentNum: 200,
							thumbNum: 200
						}
					})
				this.momentList[this.currentTab]['loadtext'] = "加载更多"
			},2000)	
		}
	}
</script>

<style scoped></style>